-
-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix RSpec/NamedSubject
when block has no body
#1668
Fix RSpec/NamedSubject
when block has no body
#1668
Conversation
Can you review this PR? 🙏 |
it 'ignores subject when block has no body' do | ||
expect_no_offenses(<<-RUBY) | ||
it "is a User" do | ||
subject.each do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a real-life example?
How did you find this in the first place?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pirj Yes, it is in the GitLab code base. See https://gitlab.com/gitlab-org/gitlab/-/issues/249446#note_1461446904
bundle exec rubocop -d --only RSpec/NamedSubject spec/lib/gitlab/github_import/importer/single_endpoint_issue_notes_importer_spec.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In total, I found 38 locations where this RSpec/NamedSubject
with EnforcedStyle: named_only
would fail because of passing an empty block to subject
's method.
spec/lib/api/helpers/authentication_spec.rb:16:6.
spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb:118:12.
spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb:130:12.
spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb:154:8.
spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb:219:4.
spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb:223:4.
spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb:231:4.
spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb:238:4.
spec/lib/gitlab/database/with_lock_retries_spec.rb:118:12.
spec/lib/gitlab/database/with_lock_retries_spec.rb:130:12.
spec/lib/gitlab/database/with_lock_retries_spec.rb:155:10.
spec/lib/gitlab/database/with_lock_retries_spec.rb:166:10.
spec/lib/gitlab/database/with_lock_retries_spec.rb:233:4.
spec/lib/gitlab/database/with_lock_retries_spec.rb:237:4.
spec/lib/gitlab/database/with_lock_retries_spec.rb:245:4.
spec/lib/gitlab/database/with_lock_retries_spec.rb:254:4.
spec/lib/gitlab/database/with_lock_retries_spec.rb:265:4.
spec/lib/gitlab/database/with_lock_retries_spec.rb:271:4.
spec/lib/gitlab/github_import/importer/protected_branches_importer_spec.rb:188:6.
spec/lib/gitlab/github_import/importer/single_endpoint_diff_notes_importer_spec.rb:32:4.
spec/lib/gitlab/github_import/importer/single_endpoint_diff_notes_importer_spec.rb:51:4.
spec/lib/gitlab/github_import/importer/single_endpoint_diff_notes_importer_spec.rb:64:4.
spec/lib/gitlab/github_import/importer/single_endpoint_issue_notes_importer_spec.rb:31:4.
spec/lib/gitlab/github_import/importer/single_endpoint_issue_notes_importer_spec.rb:50:4.
spec/lib/gitlab/github_import/importer/single_endpoint_issue_notes_importer_spec.rb:63:4.
spec/lib/gitlab/github_import/importer/single_endpoint_merge_request_notes_importer_spec.rb:32:4.
spec/lib/gitlab/github_import/importer/single_endpoint_merge_request_notes_importer_spec.rb:51:4.
spec/lib/gitlab/github_import/importer/single_endpoint_merge_request_notes_importer_spec.rb:64:4.
spec/lib/gitlab/sidekiq_logging/structured_logger_spec.rb:390:6.
spec/lib/gitlab/sidekiq_middleware/size_limiter/server_spec.rb:28:2.
spec/lib/mattermost/session_spec.rb:39:6.
spec/lib/mattermost/session_spec.rb:97:8.
spec/services/projects/lfs_pointers/lfs_object_download_list_service_spec.rb:113:12.
spec/services/projects/lfs_pointers/lfs_object_download_list_service_spec.rb:127:8.
spec/services/projects/lfs_pointers/lfs_object_download_list_service_spec.rb:135:8.
spec/services/projects/lfs_pointers/lfs_object_download_list_service_spec.rb:55:8.
spec/services/projects/lfs_pointers/lfs_object_download_list_service_spec.rb:86:8.
spec/services/projects/lfs_pointers/lfs_object_download_list_service_spec.rb:98:10.
674a20a
to
678aceb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you 😊
This MR fixes a regression for 👮♂️
RSpec/NamedSubject
withEnforcedStyle: named_only
in case a block has no body. For example:Exception/failure
Found at GitLab in https://gitlab.com/gitlab-org/gitlab/-/issues/249446#note_1461446904.
Before submitting the PR make sure the following are checked:
master
(if not - rebase it).CHANGELOG.md
if the new code introduces user-observable changes.bundle exec rake
) passes (be sure to run this locally, since it may produce updated documentation that you will need to commit).